<template>
  <div>
    <el-collapse value="common">
      <el-collapse-item title="公共配置" name="common">
        <el-form :model="widget.UI.data" label-width="80px" size="mini" class="pad-lft-rgt-10">
          <el-row :gutter="10">
            <el-col :span="12">
              <el-form-item label="默认底色">
                <PopoverColor :colorValue="widget.UI.data.trackColor">
                  <CustomColorPicker v-model="widget.UI.data.trackColor" show-alpha></CustomColorPicker>
                </PopoverColor>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="选中颜色">
                <PopoverColor :colorValue="widget.UI.data.valueColor">
                  <CustomColorPicker v-model="widget.UI.data.valueColor" show-alpha></CustomColorPicker>
                </PopoverColor>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="方向">
                <el-select v-model="widget.UI.data.layout" placeholder="请选择" class="width-100"
                           @change="directionChange">
                  <el-option label="垂直" value="vertical">
                  </el-option>
                  <el-option label="水平" value="horizontal">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="最小值">
                <el-input-number
	                v-model="widget.UI.data.minLimit"

	                controls-position="right"
	                placeholder="请设置最小值"
	                class="width-100">
                </el-input-number>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="最大值">
                <el-input-number
	                v-model="widget.UI.data.maxLimit"

	                controls-position="right"
	                placeholder="请设置最大值"
	                class="width-100">
                </el-input-number>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<script>
  import CustomColorPicker from '@/components/IDE/colorPicker/Color.vue';
  import {WidgetLevel} from "@/modules/IDE/widget/atom/widgetLevel";
  import PopoverColor from '@/components/IDE/colorPicker/Popovers.vue';
  import { deepCopy} from '@/utils';

  export default {
    name: 'LevelSpec',
    components: {
      CustomColorPicker, PopoverColor
    },
    props: {
      widget: {
        type: WidgetLevel,
        default: () => {
          return {};
        }
      }
    },
    data() {
      return {}
    },
    computed: {
      state() {
        return this.widget.getCurrentState();
      }
    },
    methods: {
      directionChange(val) {
        let rect = deepCopy(this.widget.rect)
        this.widget.rect.width = rect.height
        this.widget.rect.height = rect.width
      }
    }
  };
</script>

<style scoped></style>
